<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:if test="${empty visitor ||visitor.username eq 'guest'}">
	<c:redirect url="wel!welcome.z" />
</c:if>

<head>
	<title>新增物料信息</title>
	<style type="text/css">
	form div { width: 48%;float:left; }
	</style>

	
	<script type="text/javascript">
	var jq = jQuery;
	jq( function() {
		jq("button#emptyCode").click( function() {
		var data= jq("input#mcode").val();
		if(data.length<=0){
			alert("请先输入编码前缀，例如A1，Z9");
			return false;
		}
		var url = 'm!emptyCode.z?id='+data;
		jq.post(url,function(data){
			 jq("input#mcode").val(data);
			 });
		 return false;
		});//reg
	});
	</script>
	<script type="text/javascript">
	jq(function() {
		jq("button.valid").parents("form").validate({
			rules: {
			"input.code": {required: true,maxlength: 32},
			"input.name": {maxlength: 64},
			"input.specification": {maxlength: 2048},
			"input.footprint": {maxlength: 512},
			"input.brand": {maxlength: 64},
			"input.description": {maxlength: 2048},
			"input.supplier": {maxlength: 64},
			"input.pcbDecal": {maxlength: 512},
			"input.tmpCode": {maxlength: 32},
			"input.remark": {maxlength: 2048}
			}
		});//end validate
	});
	
	</script>
</head>

<body>
	
	<form action="m!like.z?page.currentPage=1" method="post">
		<button type="button" onClick="buttonAction(this,'m!all.z')">
			返回物料列表
		</button>
			<input type="text" name="like" value="${like }" id="like"/>
			<button type="submit">
				搜索
			</button>
		</form>

	<fieldset>
		<legend>
			新增物料:
		</legend>
	<form action="m!add.z" method="post" >
	<div id="main">
		<label >
			物料编号<span class="notice">（必须，1-32个字符之间）</span>
		<br />
		<input type="text" name="input.code" id="mcode" tabindex="1" />
		<button id="emptyCode" tabindex="2">
			搜索最大编码
		</button>
		<br />
		</label>
		
		<label >
			物料名称<span class="notice">（64个字符以内）</span>
		<br />
		<input type="text" name="input.name" tabindex="3" value="${display['material'].name}"/>
		<br />
		</label>
		
		<label >
			临时编码<span class="notice">（32个字符以内）</span>
		<br />
		<input type="text" name="input.tmpCode" tabindex="4" value="${display['material'].tmpCode}"/>
		<br />
		</label>
		
		<label >
			备注<span class="notice">（2048个字符以内）</span>
		<br />
		<textarea name="input.remark" rows="3" cols="20" tabindex="5">${display['material'].remark}</textarea>
		<br />
		</label>
		
		<label >
			采购状态
		</label>
		<br />
		<input type='radio' name="input.state" value="未发布"
			checked="checked" />
		未发布
		<c:if test="${!empty visitor && visitor.adminGrade <=1}">
					<input type='radio' name="input.state" value="推荐" />推荐
					<input type='radio' name="input.state" value="一般"
						checked="checked" />一般
					<input type='radio' name="input.state" value="不推荐" />不推荐
					<input type='radio' name="input.state" value="停用" />停用
		</c:if>
		<br />
		
		<label >
			品牌<span class="notice">（64个字符以内）</span>
		<br />
		<input type="text" name="input.brand" tabindex="6" value="${display['material'].brand}"/>
		<br />
		</label>
		
		<label >
			供货商<span class="notice">（64个字符以内）</span>
		<br />
		<input type="text" name="input.supplier" tabindex="7" value="${display['material'].supplier}"/>
		<br />
		</label>

		<label >
			收件人地址<span class="notice">（多个地址请用英文分号隔开）</span>
		</label>
		<br />
		<input type="text" name="mail.tosSplit" tabindex="8" />
		<br />
		<c:forEach var="mail" items="${display['emails']}">
			<input type="checkbox" name="mail.tos" tabindex=""
				value="${mail.email}" />${mail.email}(${mail.realname })
		</c:forEach>
		<br />
		
		<label >
			邮件内容
		</label>
		<br />
		<textarea name="mail.contentText" tabindex="9"></textarea>
		<br />
		</div>
		
		<div class="secend">
		<label >
			规格型号<span class="notice">（2048个字符以内）</span>
		<br />
		<textarea name="input.specification" rows="3" cols="20"
			tabindex="10">${display['material'].specification}</textarea>
		</label>
		<br />
		
		<label >
			器件封装<span class="notice">（512个字符以内）</span>
		<br />
		<input type="text" name="input.footprint" tabindex="11" value="${display['material'].footprint}"/>
		<br />
		</label>
		
		<label >
			器件描述<span class="notice">（2048个字符以内）</span>
		<br />
		<textarea name="input.description" rows="3" cols="20" tabindex="12">${display['material'].description}</textarea>
		<br />
		</label>
		
		<label >
			PCB封装<span class="notice">（512个字符以内）</span>
		<br />
		<input type="text" name="input.pcbDecal" tabindex="13" value="${display['material'].pcbDecal}"/>
		<br />
		</label>
		
		<input type='radio' name="newPcbDecal" value="true" />新封装
		<input type='radio' name="newPcbDecal" value="false" checked="checked" />旧封装
		</div>
		
		<div>
		<button class="valid" type="submit" tabindex="14" >
			保存
		</button>
		</div>
	</form>
	</fieldset>
</body>